﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AccidentCards
{
    public partial class SettingsForm : Form
    {
        public SettingsForm()
        {
            InitializeComponent();
        }
        private void UpdateElementsTree()
        {
            treeDictionary.Nodes.Clear();
            DataTable elementsList;
            for (int i = Convert.ToInt32(Dictionary.DictCategories.FirstCategory); i < Convert.ToInt32(Dictionary.DictCategories.LastCategory); i++)
            {
                treeDictionary.Nodes.Add(Dictionary.CateroryNames[i]);
                elementsList = Dictionary.GetElementsByCategory(i);
                for (int j = 0; j < elementsList.Rows.Count; ++j)
                {
                    treeDictionary.Nodes[i].Nodes.Add(String.Format("{0}. {1}", elementsList.Rows[j]["ElementOrder"].ToString(), elementsList.Rows[j]["Description"].ToString()));
                }

            }
        }
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            UpdateElementsTree();            
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            AddDictElement frmAddElement = new AddDictElement();
            frmAddElement.ShowDialog();
            UpdateElementsTree();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
